!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("scc-c2",[],e):"object"==typeof exports?exports["scc-c2"]=e():t["scc-c2"]=e()}(self,(()=>(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{_reset:()=>L,debug:()=>R,error:()=>I,info:()=>C,log:()=>C,setDebug:()=>T,warn:()=>x});var n={};t.r(n),t.d(n,{cmdLogEvent:()=>Mi,cmdLogPerf:()=>Fi});var r,o,i,a,u,c,f=(r="",i={document:o=Object.create({get cookie(){return r},set cookie(t){r=t}})},a={},"undefined"==typeof window?{window:i,document:o,navigator:a}:{window:window||i,document:window.document||o,navigator:navigator||a}),s=function(){return f.window},l=function(){return f.document},p=function(){return f.navigator},y=function(){var t=s().location;return t&&t.hostname?t.hostname:""},v=function(){var t=y(),e=t.split("."),n=e.length;return n>2&&(t="".concat(e[n-2],".").concat(e[n-1]),2!==e[n-2].length&&3!==e[n-2].length||2!==e[n-1].length||(t="".concat(e[n-3],".").concat(t))),t},b=function(t,e){var n=A("config")[t];if(n&&e)return n[e]},d=[{name:"EMAIL",regex:/[^@^=]+@[^@]+\.[^@^&]+/}],m=function(t,e){if("string"!=typeof t)return t;for(var n=t,r=0;r1&&void 0!==arguments[1])||arguments[1]||void 0!==t)return!0===t||1===t||"string"==typeof t&&("true"===t.toLowerCase()||"1"===t)},w=function(t){var e=parseInt(t,10);if(!isNaN(e))return e},O=function(t){return/^-?\d+$/.test(t)},j=function(t){var e;return(t=t||(null===(e=s())||void 0===e||null===(e=e.location)||void 0===e?void 0:e.search))?("?"===t.substr(0,1)&&(t=t.substring(1)),t.split("&")):[]},_=function(t,e,n){for(var r=j(n),o=r.length-1;o>=0;o--){var i=r[o].split("=");if(e){if((i[0]+"").toLowerCase()===(t+"").toLowerCase())return i[1]}else if(i[0]===t)return i[1]}},S=!1,P={},E=function(){return"true"===_("scc_debug",!0)||S},k=function(t,e){var n="".concat(t,":").concat(e);if(P[n])return P[n];var r=s().console;if((E()||e)&&r&&r[t]){var o=Function.prototype.bind?Function.prototype.bind.call(r[t],r):function(){for(var e=arguments.length,n=new Array(e),o=0;o0},yt=!1;function vt(t){return vt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vt(t)}function bt(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,r=Array(e);n1&&void 0!==arguments[1]?arguments[1]:10;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._eventQueue=[],this._sendBatchCallback=e,this._maxEvents=r,this._isFlushing=!1,this._bindHandlers(),this._processInterval=setInterval((function(){n._sendBatch()}),250)},(e=[{key:"_bindHandlers",value:function(){var t=this,e=this._hidePage.bind(this),n=this._showPage.bind(this),r=s().attachEvent,o=s().addEventListener;o?(o("beforeunload",e,!1),o("pagehide",e,!1),o("pageshow",n,!1)):r&&(r("beforeunload",e),r("pagehide",e),r("pageshow",n));var i=l(),a=i.addEventListener;a&&a("visibilitychange",function(){"hidden"===i.visibilityState&&t._hidePage(),"visible"===i.visibilityState&&t._showPage()}.bind(this))}},{key:"_hidePage",value:function(){for(this._isFlushing=!0;this._eventQueue.length>0;)this._sendBatch()}},{key:"_showPage",value:function(){this._isFlushing=!1}},{key:"_sendRequests",value:function(t){var e=this;Object.entries(t).forEach((function(t){var n=_t(t,2),r=n[0],o=n[1];try{var i=_t(r.split("|"),2),a=i[0],u={schemaId:i[1],data:[]};Object.values(o).forEach((function(t){if(t.events.length>10)for(var e=t.events.length/10,n=0;nthis._maxEvents&&this.pushEvent(N(n,{events:n.events.slice(this._maxEvents)})),u[a]=i,Math.min(n.events.length,this._maxEvents)}},{key:"_sendBatch",value:function(t){var e=0,n={},r=[];for(t&&(e+=this._processEvent(n,r,t));this._eventQueue.length>0&&e3&&void 0!==arguments[3]?arguments[3]:{},o=r.queryParams,i=r.payload,a=r.requestHeaders,u=r.credentials,c=r.sendAsBeacon,f=void 0!==c&&c,l=N({},a),y=i?JSON.stringify(i):null;if(f&&wt&&!l.Authorization&&"POST"===e)try{var v=s().Blob;p().sendBeacon(t,new v([y],l))}catch(n){Ot(t,e,y,l)}else!function(t,e,n,r,o){var i=s().fetch;gt&&i?i(t,{keepalive:!0,method:e,headers:r,body:n,credentials:o}).catch((function(o){Ot(t,e,n,r)})):Ot(t,e,n,r)}(t,e,y,l,u);!function(t,e,n,r,o){var i={endpoint:e,queryParams:n,method:r,payload:o};Q(A(t),i)}(n,t,o,e,i)}("".concat(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return"https://".concat(t?t+".":"").concat(function(){if(u)return u;var t=v();if("secureserver.net"===(t=function(t){var e=t||v();return e.indexOf("godaddy.com")>=0||e.indexOf("secureserver.net")>=0}(t)?t:"secureserver.net")){var e=b("build","env");t="prod"===e?t:"".concat(e,"-").concat(t)}return u=t}())}("csp"),"/eventbus/web?clientid=").concat(n),"POST",It,{payload:t,sendAsBeacon:r})};function Rt(t){return Rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Rt(t)}function Lt(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,r=Array(e);n=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}($t);try{for(n.s();!(e=n.n()).done;){var r=e.value;if(t.startsWith("".concat(r,".")))return!1}}catch(t){n.e(t)}finally{n.f()}return!0},te=function(t,e){"debug"===t&&T("true"===e||!0===e)},ee=function(){var t,e,n=function(){for(var t={},e=0;et.length)&&(e=t.length);for(var n=0,r=Array(e);n0;)this.process(this.asyncCommands.shift());this.loaded=!0}}])&&le(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function ve(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n0&&!this.allowedValuesList.includes(t))throw"Input '".concat(t,"' for property '").concat(this.name,"' is not one of the allowed values (").concat(this.allowedValuesList,").")}},{key:"optional",value:function(){return this._fieldType=ke,this}},{key:"required",value:function(){return this._fieldType=Te,this}},{key:"stringify",value:function(){for(var t=new et,e=0;e0)try{n=Re(e,"parse",this,3)([t||{}])}catch(t){throw""}return Object.freeze(n)}}])}(Ke),He=function(t){function e(){return Me(this,e),Ie(this,e,arguments)}return De(e,t),qe(e,[{key:"parse",value:function(t){return this.validate(t),t}},{key:"stringify",value:function(){var t={};return t[this.name]=this._fieldType,t}}])}(Ke),ze=function(t){function e(){return Me(this,e),Ie(this,e,arguments)}return De(e,t),qe(e,[{key:"pattern",value:function(t){return this._pattern=t,this}},{key:"validate",value:function(t){Re(e,"validate",this,3)([t]);var n=Ne(t);if("string"===n){if(this._pattern&&!t.match(this._pattern))throw"Input ".concat(t," does not match ").concat(this._pattern)}else if("undefined"!==n&&null!=t)throw"Input is not a string"}},{key:"stringify",value:function(){var t=Re(e,"stringify",this,3)([]),n=this._pattern?" | pattern: ".concat(this._pattern):"";return t[this.name]="".concat(t[this.name]," | type: string").concat(n),t}}])}(He),We=function(t){function e(){var t;return Me(this,e),(t=Ie(this,e)).definitionType="Object",t}return De(e,t),qe(e,[{key:"stringify",value:function(){if(this._resolutionType===Ce){var t={};return t["".concat(this.name," (").concat(this._fieldType,")")]=Re(e,"stringify",this,3)([]),t}return Re(e,"stringify",this,3)([])}},{key:"substitute",value:function(t){return this.properties=this.properties.concat(t),this._resolutionType="sub",this}},{key:"map",value:function(t,e){return this.name=t,this.properties=this.properties.concat(e),this._resolutionType=Ce,this}},{key:"extend",value:function(t){return t&&(this.properties=this.properties.concat(t)),this}}])}(Ke),$e=function(t){function e(){var t;return Me(this,e),(t=Ie(this,e)).definitionType="Collection",t.minElements=0,t}return De(e,t),qe(e,[{key:"parse",value:function(t){if(this.minElements&&(!t||t.length0?Te:ke,this}}])}(We);function Qe(t){return Qe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Qe(t)}function Je(t){return function(t){if(Array.isArray(t))return Ze(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Ze(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ze(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ze(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n=0;e--){var n=this.asyncCommands[e];n.schema!==this.pageViewSchema||n.data&&n.data.virtual_path||(t=!1),"set_config"===n.schema&&this.process.apply(this,Je(this.asyncCommands.splice(e,1)))}t&&this.process({schema:this.pageViewSchema})}},{key:"process",value:function(t){en(n,"pushLog",this,3)([t]);try{var r=t.data,o=t.schema||t.interface,i=t.type,a=t.version||"v1",u=t.targets||[],c={eventId:ce()};this.beforeEvent&&this.beforeEvent(),function(){for(;Xtt.length)&&(e=t.length);for(var n=0,r=Array(e);n=0;n--)e[n]=e[n].trim(),e[n]||e.splice(n,1);if(e.length>0)for(;e.length<3;)e.push("Other");return e.join(" / ")}()},"page.host":function(){return y()},"page.path":function(t){return t.win.location.pathname},"page.virtualPath":function(){return hn.get("virtual_path")},"page.location":function(){return n=(t=j()).length?(function(t){for(var e=0;et.length)&&(e=t.length);for(var n=0,r=Array(e);n0&&or(t,e,o)):n.events.forEach((function(n){r&&!r.includes(n.schemaId)||or(t,e,N(o,{event:n}))}))},ar=function(t,e){var n=fr();n.length>=ur&&x("".concat(t," subscribed to SCC after the eventQueue was full. Some events may have been lost.")),n.forEach((function(n){return ir(t,e,n)})),nr[t]=e},ur=2e3,cr=[],fr=function(){return[].concat(cr)},sr="urn:shared:user:event:/data-platform/signals/click/v1",lr="urn:shared:user:event:/data-platform/signals/impression/v1",pr="urn:shared:user:event:/data-platform/signals/element-action/v1",yr="urn:shared:user:event:/data-platform/signals/traffic-event/v1",vr="urn:shared:user:event:/data-platform/signals/experiment-assignment/v1",br="urn:shared:user:event:/appconfig/id-percentage-evaluation/v1",dr=function(t){var e,n,r=t.globalSchemaId,o=t.businessContext,i=t.events,a=t.webContext,u=t.routing,c=void 0===u?{}:u,f=c.eventBusApiKey,s=c.hasConversion,l=c.targets;if($(i)&&0!==i.length){for(var p,y=W(),v=0;vur&&cr.shift()}};function mr(t){return mr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mr(t)}function hr(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},e=t.eid,n=t.customProperties,r=t.eventCategory;return N({pageLevelProperties:N(Zt),identityRealm:Ht("identity","realm")},e&&{eid:e},n&&{customProperties:n},r&&{eventCategory:r})},Ar=function(t,e,n,r){var o={traffic:Lr({eid:e,customProperties:r}),producerEventId:t};if(e){var i=function(t){return t.split(".")}(e),a=function(t){return t[t.length-1]}(i);(function(t){return!!(t.match(Rr)&&t.length<=500)})(e)&&function(t,e,n){return e===n&&t.length>=5&&t.length<=6}(i,a,n)&&(o.element=function(t,e){var n=6===t.length?1:0,r={area:t[0],product:t[1],section:t[2+n],widget:t[3+n]};return["impression","click"].includes(e)||(r.action=e),r}(i,a))}return o},Dr=function(t,e,n,r){null!=r&&null!=n&&0!==r&&0!==n&&n>r&&(t[e]=Math.round(n-r))},Br=function(t,e,n,r){var o=ct(e);!function(t,e){Dr(t,"pageLoadTime",e.loadEventStart,e.navigationStart),Dr(t,"domContentLoadedTime",e.domContentLoadedEventStart,e.navigationStart),Dr(t,"domInteractiveTime",e.domInteractive,e.navigationStart),Dr(t,"pageDownloadTime",e.responseEnd,e.responseStart),Dr(t,"domainLookupTime",e.domainLookupEnd,e.domainLookupStart),Dr(t,"serverResponseTime",e.responseStart,e.requestStart),Dr(t,"serverConnectionTime",e.connectEnd,e.connectStart),Dr(t,"redirectionTime",e.fetchStart,e.navigationStart)}(o,e);var i={navigationType:e.navigationType,timing:{navigation:o},traffic:Lr({customProperties:n}),producerEventId:t,contentLoadType:r};return"hard"===r&&(i.response=ft(e),i.timing.marks=e.marks,i.timing.measures=e.measures,i.timing.paint={firstPaint:e.fp,firstContentfulPaint:e.fcp,largestContentfulPaint:e.lcp}),i},Mr=function(t,e,n){return{timing:{paint:{largestContentfulPaint:e.LCP},vitals:{cumulativeLayoutShift:e.CLS,firstInputDelay:e.FID,timeToInteractive:e.timeToInteractive,interactionToNextPaint:e.INP}},traffic:Lr({customProperties:n}),producerEventId:t}};function Fr(t){return Fr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fr(t)}function qr(t,e){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:"".concat(e.area,".").concat(e.product,".").concat(e.section,".").concat(e.widget,".").concat(t)}},{key:"_transformLegacyPromo",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.eid,o=n.customProperties,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return{id:i.id,name:i.name,creative_name:i.creative,creative_slot:i.position,type:t,properties:o,eid:this._buildLegacyEid(t,e,r)}}},{key:"_isPromo",value:function(t){return t.promotion&&Object.keys(t.promotion).length>0}}],r&&qr(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r}(_r);function Hr(t){return Hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Hr(t)}function zr(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,r=Array(e);n